package com.ppx.life.controller;

import com.ppx.life.dao.User;
import com.ppx.life.dao.vo.Conversation;
import com.ppx.life.dao.vo.DataObject;
import com.ppx. life.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 这个类作为一个控制器，配置相应处理
 */
@RequestMapping("/v1/")
@Controller
public class MainController {
    @Autowired
    private UserService userService;

    //处理注册请求
    @RequestMapping("register")
    @ResponseBody
    public Conversation addUser(User user){
        DataObject object = userService.register(user);
        return new Conversation(object);
    }

    @RequestMapping("login")
    @ResponseBody
    public Conversation loginCheck(User user){
        DataObject object = userService.loginCheck(user);
        return  new Conversation(object);
    }

}
